//
//  MysearchCollectionViewCell.m
//  UI_HLJ_Frame
//
//  Created by  毕宏伟 on 15/7/8.
//  Copyright (c) 2015年 毕宏伟. All rights reserved.
//

#import "MysearchCollectionViewCell.h"
#import "MysearchPageTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "SearchPageModel.h"
#import "contentModel.h"
#import "MysearchtwoPaegTableViewCell.h"
#import "itemstwoModel.h"
#import "contenttwoModel.h"
@implementation MysearchCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self =[super initWithFrame:frame];
    if (self) {
        self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height) style:UITableViewStyleGrouped];
        self.tableView.backgroundColor =[UIColor whiteColor];
        self.tableView.delegate= self;
        self.tableView.dataSource =self;
        self.tableView.separatorStyle =UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.tableView];
//        self.tableView.rowHeight =200;
        [_tableView release];
        
    }
    return self;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (self.flag==0) {
        return self.onePageArr.count;
    }
    else
    {
        return self.twoPageArr.count;
    }

}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.flag==0) {
        NSString *reuse =@"reuse";
        MysearchPageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse];
        if (!cell) {
            cell =[[[MysearchPageTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuse]autorelease];
            
        }
        SearchPageModel *se =self.onePageArr[indexPath.row];
        cell.titleLabel.text =se.title;
        contentModel *con =self.contentArr[indexPath.row];
        cell.addressLabel.text =con.merchant_name;
        cell.priceLabel.text =[NSString stringWithFormat:@"💰%@",con.actual_price];
        [cell.bigImage sd_setImageWithURL:[NSURL URLWithString:se.imgpath]];
        return cell;
    }
    else
    {
        NSString *reuse1 =@"reuse1";
        MysearchtwoPaegTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse1];
        if (!cell) {
            cell =[[[MysearchtwoPaegTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuse1]autorelease];
        }
        
        itemstwoModel *it =self.twoPageArr[indexPath.row];
        cell.titleLabel.text =it.title;
        contenttwoModel *con =self.contenttwoArr[indexPath.row];
        cell.addressLabel.text =con.merchant_name;
        cell.shoucangLabel.text =[NSString stringWithFormat:@"❤️%@",it.likecount];
        [cell.bigImage sd_setImageWithURL:[NSURL URLWithString:it.imgpath]];
        return cell;
        
    }

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.flag ==0) {
        return 300;
    }
    else
    {
        return 300;
    }
}

@end

